package top.lyc829.zzl_android.ui.thing.travels;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.module.LoadMoreModule;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

import top.lyc829.zzl_android.R;
import top.lyc829.zzl_android.logic.bean.DynamicBean;
import top.lyc829.zzl_android.logic.bean.TravelsSimpleBean;
import top.lyc829.zzl_android.logic.util.RichUtils;

public class TravelsAdapter extends BaseQuickAdapter<TravelsSimpleBean, BaseViewHolder> implements LoadMoreModule {
    public TravelsAdapter() {
        super(R.layout.travel_item);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, TravelsSimpleBean travelsSimpleBean) {
        baseViewHolder.setText(R.id.travel_item_title, travelsSimpleBean.getTitle());
        baseViewHolder.setText(R.id.travel_item_text, RichUtils.returnOnlyText(travelsSimpleBean.getText()));

        if (RichUtils.returnImageUrlsFromHtml(travelsSimpleBean.getText()).get(0).length() == 0) {
            ((ImageView) baseViewHolder.getView(R.id.travel_item_image)).setVisibility(View.GONE);
        } else {
            ((ImageView) baseViewHolder.getView(R.id.travel_item_image)).setVisibility(View.VISIBLE);
            Glide.with(getContext())
                    .load(RichUtils.returnImageUrlsFromHtml(travelsSimpleBean.getText()).get(0))
                    .into((ImageView) baseViewHolder.getView(R.id.travel_item_image));
        }



    }
}
